package com.ophiux.service.order.api.impl;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.ophiux.service.order.api.MemberService;
import com.ophiux.service.order.api.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderServiceImpl implements OrderService {
    @Autowired
    MemberService memberService;

    @Override
    @SentinelResource(value = "orderToFeignMember", blockHandler = "getOrderQpsException")
    public String orderToFeignMember() {
        String result = memberService.getUser("1");

        return "订单调用会员，返回参数："+result;
    }
    /**
     * 被限流后返回的提示
     * @param e
     * @return
     */
    public String getOrderQpsException(BlockException e) {
        e.printStackTrace();
        return "该订单接口已经被限流啦!";
    }
}
